package com.dispatcher;

import android.app.Activity;
import android.app.Application;

import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.zuzhili.database.ZuZhiLiDBCtrl;

public class GlobalVar extends Application {
	public boolean g_bexist;
	public int g_guidever=1;
	byte[] glocker;
	// 数据库实例唯一
	public ZuZhiLiDBCtrl  g_dbctrl;
	
	// 网络连通状态唯一
	
	// 用户数据
	public DisplayImageOptions options_head;
	public DisplayImageOptions options_pic;
	public Activity g_hometabIS;
	
	@Override
	public void onCreate() {
		glocker=new byte[0];
		// This configuration tuning is custom. You can tune every option, you may tune some of them, 
		// or you can create default configuration by
		//  ImageLoaderConfiguration.createDefault(this);
		// method.
		options_pic = new DisplayImageOptions.Builder()
		.showStubImage(R.drawable.photo_default)
		.showImageForEmptyUri(R.drawable.photo_default)
		.cacheInMemory()
		.cacheOnDisc()
//		.displayer(new RoundedBitmapDisplayer(20))
		.build();

		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
			.threadPoolSize(3)
			.threadPriority(Thread.NORM_PRIORITY - 2)
			.memoryCacheSize(3000000) // 1.5 Mb
			.denyCacheImageMultipleSizesInMemory()
			.discCacheFileNameGenerator(new Md5FileNameGenerator())
			.enableLogging() // Not necessary in common
			.build();
		// Initialize ImageLoader with configuration.
		ImageLoader.getInstance().init(config);
	}
	
	public void initDBCtrl(String email){
		g_dbctrl=new ZuZhiLiDBCtrl(getApplicationContext(),email);
	}
}